package question1;

import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
/**
 *
 * @author Avuyile
 */
public class Elimination {
     public static void main(String[] args) {
         
        Scanner input = new Scanner(System.in);
        String[] names = new String[6];

        for (int i = 0; i < names.length; i++) {
            System.out.println("Please Enter A Name: ");
            names[i] = input.nextLine();
        }
        
        List<String> list = Arrays.asList(names);
        
        System.out.printf("Initial Array%s: ", list);
        System.out.println();

        removeDuplicates(list);
        searchName(list);

    }

    private static void removeDuplicates(Collection<String> values) {
        Set<String> set = new HashSet<String>(values);
        
        for (String value : set) {
            System.out.printf("Non-duplicate list: %s\n", value);
        }
        System.out.println();
    }
    
    public static void searchName(Collection<String> names) {
        String someName ="";

        Set<String> set = new HashSet<String>(names);
        Scanner input = new Scanner(System.in);

        for (int i = 0; i < 1; i++) {
            System.out.println("Search a name: ");
            someName = input.nextLine();
        }

        if(set.contains(someName)) {
                System.out.println("Set contains name!");
        }else {
          System.out.println("Set doesn't contain this name!");
        }
    }
}

